"""
【状态转移】
状态模式(State Pattern)
允许对象在其内部状态发生改变时改变它的行为。这个模式将一个对象的状态从该对象中移出来，并将其封装到不同的状态对象中。
"""
from abc import ABC, abstractmethod


class State(ABC):
    @abstractmethod
    def handle(self):
        pass


class ConcreteStateA(State):
    def handle(self):
        print("Handling state A")
        return ConcreteStateB()


class ConcreteStateB(State):
    def handle(self):
        print("Handling state B")
        return ConcreteStateC()


class ConcreteStateC(State):
    def handle(self):
        print("Handling state C")
        return ConcreteStateA()


class Context:
    def __init__(self, initial_state):
        self.state = initial_state

    def request(self):
        self.state = self.state.handle()


context = Context(ConcreteStateA())
context.request()
context.request()
context.request()
"""
Handling state A
Handling state B
Handling state C
"""
